<template>
	<view class="agritainment">
		<view class="title-image">
			<text @click="back()" class="back iconfont icon-left"></text>
			<image :src="agritainmentData.mainImage" mode=""></image>
		</view>
		<view class="infnfo">
			<view class="title">
				<text>{{agritainmentData.title}}</text>
			</view>
			<view class="hotel-tip"  v-if="agritainmentData.subTitle">
				<block v-for="(lab,index) in agritainmentData.subTitle"  :key="index">
					<view class="tips">
						<text>{{lab}}</text>
					</view>
				</block>
			</view>
			<view class="address">
				<text style="margin-right: 10uxp;line-height: 45upx;">地址: {{agritainmentData.address}}</text>
				<text style="color: #0092ff;float: right;" class="mapss" @click="goWay()">地图<text class="iconfont icon-right"></text></text>
				<view style="clear: both;"></view>
			</view>
			<view class="dividingLine"></view>
		</view>
		<view class="variety-dishes">
			<view class="variety-dishes-box">
				<view class="variety-dishes-icon"></view>
				<view class="variety-dishes-title">
					<text>{{title}}</text>
				</view>
			</view>
			<view class="variety-dishes-food">
				<text>{{agritainmentData.digest}}</text>
			</view>
		</view>
		<view class="division"></view>
		<view class="introduce" v-if="agritainmentData.context">
			<view class="introduce-title">
				<text>详情介绍</text>
			</view>
			<view style="line-height: 100upx;">
				<u-parse :noData="agritainmentData.empty" :content = "agritainmentData.context"></u-parse>
			</view>
		</view>
		<view class="division" v-if="agritainmentData.context"></view>
		<view class="popular-travels">
			<view class="popular-travels-title">
				<text>热门推荐</text>
			</view>
			 <view class="popular-travels-list-boxs">
				 <block v-for="(item,index) in recommendTravels" :key="index">
					 <view class="popular-travels-list" @click="goToTravel(item.id,item.type)">
						 <view class="popular-travels-list-img">
							 <image :src="item.otherImage" style="width: 100%;height: 100%;border-radius: 6px 6px 0px 0px;"></image>
							 <view class="discover-travelist-aers">
							 	<!-- <text class="iconfont icon-location-fill" style="margin-right: 5upx;"></text> -->
							 	<text>{{item.type}}</text>
							 </view>
						 </view>
						
						 <view class="popular-travels-list-info">
							 <view class="popular-travels-list-text">
								 <text>{{item.title}}</text>
							 </view>
							 <view class="popular-travels-role">
								 <!-- <view class="popular-travels-list-headPortrait">
									<image style="width: 100%;height: 100%;border-radius: 50%;" :src="item.headPortrait"></image>
								 </view> -->
								 <view>
									<view class="popular-travels-list-author">
										<text>{{item.readCount || '0'}}人浏览</text>
									</view>
									 <!-- <view class="popular-travels-list-time">
										 <text>{{item.sendTime}}</text>
									 </view> -->
								 </view>
							 </view>
							 
						 </view>
					 </view>
				 </block>
			 </view>
		</view>
		<view class="line-phone" @click="callPhone()" v-if="fleg == 'true'">
			<text>电话预定</text>
		</view>
	</view>
</template>

<script>
	import Header from '@/components/header.vue'
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
	import uParse from "@/components/gaoyia-parse/parse.vue"

	// 	var _self,
	// 			page = 1,
	// 			timer = null;
	var innerAudioContext = uni.createInnerAudioContext();
	export default {
		data() {
			return {
				fleg:true,
				title:'',
				recommendTravels:[],
				scenicId:'',
				agritainmentData:{},
			}
		},
		components: {
			Header,
			uniLoadMore,
			uniNavBar,
			uParse
		},
		onLoad: function(option) {
			console.log("传过来的参数>>>>>>>>>>>>>>>>>>",option)
			this.fleg = option.fleg
			this.scenicId = option.id;
			this.title = option.title
			this.getNewTravels_discover()
		},
		onShow:function(){
			//#ifdef H5
			document.title = '景区详情'
			//#endif
		},
		onReachBottom: function() {
			this.page++
			if (this.isOnReachBottom) {
				this.updateTuijians(this.tabVal)
			}
		},
		mounted() {
			// this.getCommentList();
			this.getScenceDetails();
			// this.getSpotDetails()
			// this.getTicketBySpotId();
		},
		methods: {
			getNewTravels_discover(attribute){
				var that = this
				// this.recommendTravels = []
				var param = {
					channelType: '1',
					city:this.citys
				}
				this.$postApi(this.$path.GET_RECOMMEND_LIST,param).then(res=>{
					// this.recommendTravels = []
			
					// this.recommendTravels = res.data.data.list
					let list = res.data.data
					console.log("返回热门推荐列表目的地",res)
					if (res.data.success) {
						list.forEach(item => {
							item.otherImage = this.pub.delLastf(item.otherImage)
							if(item.readCount == null || item.readCount == "null"){
								item.readCount = 0
							}
							switch(item.type){
								case "1":
									item.type = "景区"
								break;
								case "2":
									item.type = "酒店"
								break;
								case "3":
									item.type = "游记"
								break;
								case "4":
									item.type = "餐厅"
								break;
								case "5":
									item.type = "美食"
								break;
								case "6":
									item.type = "农家乐"
								break;
							}
						})
					this.recommendTravels = list
					}	
				})
				
			},
			goToTravel:function(id,type){
				console.log(type)
				var url = ''
				switch(type){
					case "景区":
						url = '/pages/scence/scencedetail?id=' + id
					break;
					case "酒店":
						url = '/pages/hotel/hoteldetail?hotelid=' + id
					break;
					case "游记":
						url = '/pages/travelDetail/travelDetail?id=' + id
					break;
					case "餐厅":
						url = '/pages/restaurant/restaurant_detail?id=' + id
					break;
					case "美食":
						url = '/pages/food/foodlist_new?id=' + id
					break;
					case "农家乐":
						url = '/pages/agritainment/agritainmentdateil?id=' + id + '&title='+ '菜品介绍'
					break;
				}
				uni.navigateTo({
					url:url,
					animationType: 'pop-in',
					animationDuration: 200
				})
			},
			//获取农家乐数据
			getScenceDetails(){
				var that = this;
				var params = {
					id:this.scenicId,
				}
				this.$postApi(this.$path.GET_NEW_DESTINATION_DETAIL,params).then(res => {
					console.log("农家乐详情返回数据----------->",res.data);			
					if(res.data.success){
						this.agritainmentData = res.data.data
						var datas = res.data.data
						this.agritainmentData.subTitle = this.agritainmentData.subTitle ? this.agritainmentData.subTitle.toString().split(','): ''
						if (datas.address.length > 15) {
							this.agritainmentData.address = datas.address.slice(0, 15) + '...'
						} else {
							this.agritainmentData.address = datas.address
						}
						
						this.agritainmentData.digest = datas.digest.replace(/,/g," "+" / "+" "+" ");
						
					}
				})
			},
			back() {
				uni.navigateBack({
					delta: 1
				});
			},
			goWay() {
				var maps = JSON.parse(this.agritainmentData.degree)
				var location = {
					latitude:"",
					longitude:""
				};
				maps.forEach(item=>{
					// item.commentator.headPortrait = this.pub.fmtImgUrl(item.commentator.headPortrait);
					if(item.type == "tengxun"){
						location.latitude = item.latitude,
						location.longitude = item.longitude
					};
				})
				uni.navigateTo({
					url:'../map/map?item=' + encodeURIComponent(JSON.stringify(location))
				})
				// uni.showToast({
				// 	title: '此功能暂未开通！',
				// 	icon: 'none',
				// 	duration: 2000
				// });
					
			},
			callPhone(){
				uni.makePhoneCall({
				    phoneNumber: this.agritainmentData.phone //仅为示例
				});
			}
				
		},
		
	}
</script>

<style lang="scss" scoped>
	.popular-travels{
		margin-bottom: 90upx;
	}
	.popular-travels-role{
		display: flex;
		padding-bottom: 30upx;
	}
	.popular-travels-list-headPortrait{
		width: 36upx;
		height: 36upx;
		margin-right: 8upx;
		// border-radius: 50%;
	}
	.popular-travels-list-author{
		margin-bottom: 10upx;
		font-family: PingFang-SC-Medium;
		font-size: 26upx;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 0upx;
		color: #333333;
		opacity: 0.9;
	}
	.popular-travels-list-time{
		font-family: PingFang-SC-Medium;
		font-size: 20upx;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 0upx;
		color: #999999;
		opacity: 0.9;
	}
	.popular-travels-title{
		padding: 40upx 0 17upx 24upx;
		font-family: PingFang-SC-Bold;
		font-size: 44upx;
		font-weight: bold;
		font-stretch: normal;
		letter-spacing: 0upx;
		color: #000000;
	}
	.popular-travels-list{
		width: 48.5%;
		margin-bottom: 24upx;
		background-color: #f3f4f8;
		border-radius: 0px 0px 6px 6px;
		
	}
	.discover-travelist-aers{
		padding: 5upx 12upx;
		background-color: #353638;
		border-radius: 20upx;
		opacity: 0.8;
		position: absolute;
		bottom:15upx;
		right: 15upx;
		font-family: PingFang-SC-Bold;
		font-size: 24upx;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 0upx;
		color: #ffffff;
	}
	.popular-travels-list-info{
		padding: 20upx 13upx 0 13upx;
	}
	.popular-travels-list-boxs{
		background: #fff;
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		padding: 18upx 24upx 24upx 24upx;
		
		
	}
	.popular-travels-list-img{
		position: relative;
		width: 100%;
		height: 267upx;
	}
	.popular-travels-list-text{
		width: 100%;
		overflow:hidden;
		text-overflow:ellipsis;
		white-space:nowrap;
		line-height: 40upx;
		margin-bottom: 20upx;
		font-family: PingFang-SC-Bold;
		font-size: 32upx;
		font-weight: 600;
		font-stretch: normal;
		letter-spacing: 0upx;
		color: #1a1a1a;
	}
	.line-phone{
		// margin-top: 180upx;
		position: fixed;
		bottom: 0;
		text-align: center;
		width: 100%;
		height: 108upx;
		color: #fff;
		background: #0092FF;
		font-family: PingFang-SC-Bold;
		font-size: 36upx;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 5upx;
		line-height: 108upx;
	}
	.dividingLine{
		width: 100%;
		height: 1upx;
		background-color: #f2f2f2;
		margin: 0 auto;
		margin-top: 20upx;
	}
	.mapss:after{
		content:".";
		height:0;
		visibility:hidden;
		display:block;		
		clear:both;
	}
	.agritainment{
		 height: 100%;
		  min-height: 100%;
		  font-size: 32rpx;
		  background: #fff;
		.title-image{
			position: relative;
			width: 100%;
			height: 445upx;
			.back{
				position: fixed;
				top:65upx;
				left: 25upx;
				border-radius: 50%;
				width: 60upx;
				height: 60upx;
				display: flex;
				justify-content: center;
				align-items: center;
				background: rgba(255,255,255,0.6);
				text{
					font-size: 45upx;
				}
				
				z-index: 20;
			}
			image{
				width: 100%;
				height: 100%																					;
			}
		}
		.title{
			font-family: PingFang-SC-Bold;
			font-size: 54upx;
			font-weight: bold;
			font-stretch: normal;
			letter-spacing: 1upx;
			color: #000000;
		}
		.address{
			// line-height: 55upx;
			// padding: 42upx 22upx 42upx 22upx;
			font-family: PingFang-SC-Medium;
			font-size: 28upx;
			font-weight: normal;
			font-stretch: normal;
			// line-height: 46px;
			letter-spacing: 0upx;
			color: #333333;
			margin-top: 23upx;
		}
		.infnfo{
			padding: 50upx 25upx 34upx 25upx;
			background-color: #ffffff;
			position: relative;
			margin-top: -22upx;
			border-radius: 26upx;
		}
		.address text:last-child{
			text-align: right;
		}
		.division{
			width: 100%;
			height: 22upx;
			background: #f7f7f7;
		}
		.introduce{
			padding: 40upx 25upx;
			.introduce-title{
				margin-bottom: 37upx;
				font-family: PingFang-SC-Bold;
				font-size: 44upx;
				font-weight: bold;
				font-stretch: normal;
				letter-spacing: 0rpx;
				color: #000000;
			}
		}
	}
	.hotel-tip{
		margin-top: 20upx;
		font-family: PingFang-SC-Medium;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		width: 100%;
		justify-content: flex-start;
		color: #0092ff;
		font-size: 26upx;
		.tips{
			margin-right: 10upx;
			padding: 2upx 8upx 2upx 8upx;
			// width: 200upx;
			border-radius: 6upx;
			border: 1upx solid #0092ff;
		}
	}
	.variety-dishes{
		padding-left: 25upx;
		padding-bottom: 32upx;
		padding-top: 10upx;
		.variety-dishes-box{
			display: flex;
			line-height: 35upx;
		}
		.variety-dishes-icon{
			margin-right: 8upx;
			width: 5upx;
			height: 36upx;
			background-image: linear-gradient(0deg, 
				#0092ff 0%, 
				#00c0ff 100%);
			border-radius: 3upx;
		}
		.variety-dishes-title{
			font-family: PingFang-SC-Bold;
			font-size: 36upx;
			font-weight: bold;
			font-stretch: normal;
			letter-spacing: 1upx;
			color: #1a1a1a;
		}
		.variety-dishes-food{
			padding-top: 14upx;
			font-family: PingFang-SC-Medium;
			font-size: 28upx;
			font-weight: normal;
			font-stretch: normal;
			line-height: 50upx;
			letter-spacing: 0upx;
			color: #212121;
		}
	}
</style>